﻿using System;
using System.Collections.Generic;
using System.Text;

namespace 状态者模式
{
    // Red State意味着Account透支了
    class RedState : State
    {
        public RedState(State state)
        {
            this.Balance = state.Balance;
            this.Account = state.Account;
            Interest = 0.00;
            LowerLimit = -100.00;
            UpperLimit = 0.00;
        }

        public override void Deposit(double amount)
        {
            Balance += amount;
            StateChangeCheck();
        }

        public override void PayInterest()
        {
           
        }

        public override void Withdraw(double amount)
        {
            Console.WriteLine("没有钱可以取了！");
        }

        private void StateChangeCheck()
        {
            if (this.Balance > UpperLimit)
            {
                this.Account.State = new SilverState(this);
            }
        }
    }
}
